@extends('backend::layout')
@section('title',$page_title)
@push('styles')
    <link href="{{asset(config('view.plugin').'/layui/layui_ext/cascader/cascader.css')}}" rel="stylesheet">
@endpush
@include('backend::component.upload.upload_js')
@section('content')
    <div class="row">
        <div class="col-lg-12">
                @component('backend::component.form.form')
                @slot('form_title') {{$page_title}} @endslot
                @slot('formId') add-article @endslot
                @slot('enctype') multipart/form-data @endslot
                @slot('action') {{route('b_Article_addArticle')}} @endslot

                    @component('backend::component.form.form-group')
                        @slot('title') 文章标题 @endslot
                        @component('backend::component.form.input')
                            @slot('name') title @endslot
                        @endcomponent
                    @endcomponent

                    @component('backend::component.form.form-group')
                        @slot('title') 副标题 @endslot
                        @component('backend::component.form.input')
                            @slot('name') subtitle @endslot
                        @endcomponent
                    @endcomponent

                    @component('backend::component.form.form-group')
                        @slot('title') 文章分类 @endslot
                        <div class="layui-input-block">
                            <input type="text" id="category" data-categories='{{$categories}}'
                                   class="form-control" readonly
                            >
                            <input type="hidden" id="cat-value" name="cat_id"  value="">
                        </div>
                    @endcomponent

                    @component('backend::component.form.form-group')
                        @slot('title') 文章封面 @endslot
                        @component('backend::component.upload.upload_img')
                            @slot('name') thumb @endslot
                            @slot('group') article @endslot
                        @endcomponent
                    @endcomponent

{{--                    @component('backend::component.form.form-group')--}}
{{--                        @slot('title') 上传音频-听录音分类有效 @endslot--}}
{{--                        @component('backend::component.form.input')--}}
{{--                            @slot('name') mp3 @endslot--}}
{{--                            @slot('type') file @endslot--}}
{{--                            @slot('value')  @endslot--}}
{{--                        @endcomponent--}}
{{--                    @endcomponent--}}

{{--                    @component('backend::component.form.form-group')--}}
{{--                        @slot('title') 上传视频-看视频分类有效 @endslot--}}
{{--                        @component('backend::component.form.input')--}}
{{--                            @slot('name') mp4 @endslot--}}
{{--                            @slot('type') file @endslot--}}
{{--                            @slot('value')  @endslot--}}
{{--                        @endcomponent--}}
{{--                    @endcomponent--}}

                    @component('backend::component.form.form-group')
                        @slot('title') 内容 @endslot
                        @component('backend::component.ckedit')
                            @slot('name') content @endslot
                            @slot('loading_js') true @endslot
                        @endcomponent
                    @endcomponent

                    @component('backend::component.form.form-group')
                        @slot('title') 排序 @endslot
                        @component('backend::component.form.input')
                            @slot('name') sort @endslot
                            @slot('value') 1000 @endslot
                        @endcomponent
                    @endcomponent

                    @component('backend::component.form.form-group')
                        @slot('title') 描述 @endslot
                        @component('backend::component.form.textarea')
                            @slot('name') description @endslot
                        @endcomponent
                    @endcomponent

                    @component('backend::component.form.form-group')
                        @slot('title') 关键词 @endslot
                        @component('backend::component.form.textarea')
                            @slot('name') key_words @endslot
                        @endcomponent
                    @endcomponent

                    @component('backend::component.form.form-group')
                        @slot('title') 是否发布 @endslot
                         <div>
                            @foreach(['1'=>'是','0'=>'否'] as $value=>$title)
                                @component('backend::component.radio')
                                    @slot('title') {{$title}} @endslot
                                    @slot('name') is_open @endslot
                                    @slot('value') {{$value}} @endslot
                                    @if($value == 1)
                                        @slot('checked') checked @endslot
                                    @endif
                                 @endcomponent
                            @endforeach
                         </div>
                    @endcomponent



                @slot('buttons')
                        <button type="submit" class="btn-min-width btn btn-sm btn-primary mr-1" data-params="{&quot;formId&quot;:&quot;#add-article&quot;}">
                            提交
                        </button>
                   {{-- @component('backend::component.form.button')
                        @slot('title') 提交 @endslot
                        @slot('params') {"formId":"#add-article"} @endslot
                        @slot('class') btn-min-width ajax-form @endslot
                    @endcomponent--}}
                    @component('backend::component.form.button')
                        @slot('title') 重置 @endslot
                        @slot('type') reset @endslot
                        @slot('color') danger @endslot
                        @slot('class') btn-min-width @endslot
                    @endcomponent
                @endslot
            @endcomponent
        </div>
        <!--/.col-->
    </div>
@endsection
@push('scripts')
    <script>
        layui.use(['jquery','cascader'], function(){
            var $ = layui.jquery;
            var cascader = layui.cascader;
            selectParentAction();
            function selectParentAction() {
                var data = $('#category').data('categories');
                cascader({
                    elem: "#category",
                    data: data,
                    triggerType: "change",
                    //showLastLevels:true,
                    //value: ["0"],
                    changeOnSelect:true,
                    success:function (valData) {
                        $('#cat-value').val(valData[valData.length-1]);
                    }
                });
            }
        });
    </script>
@endpush